﻿@{
    ViewBag.Title = "产品列表";
    Layout = "~/Areas/Shared/_spEdit.cshtml";
   
}
@using Kaiser.Extensions
@model Kaiser.Modules.Cubic.DomainModel.Advert.Advert
<link href="@Url.Content("~/Scripts/Uploadify/3.1/uploadify.css")" rel="stylesheet"  type="text/css" />
<script src="@Url.Content("~/Scripts/Uploadify/3.1/swfobject.js")"   type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/Uploadify/3.1/jquery.uploadify-3.1.min.js")"   type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/Plugins/jquery-jtemplates.js")"   type="text/javascript"></script>


<form method="post">

    <table>

        <tr>
            <td>标题：
            </td>
            <td>
                @Html.Hidden("Id", Model.Id)
                @Html.TextBoxFor(m => Model.Title, new { @Class = "easyui-validatebox", @required = "true" })
            </td>
        </tr>

        <tr>
            <td>广告语：
            </td>
            <td>
                @Html.HiddenFor(m => Model.SpaceId)
                @Html.TextBoxFor(m => Model.Poster, new { @Class = "easyui-validatebox", @required = "true" })

            </td>
        </tr>
        <tr>
            <td>拼音缩写：
            </td>
            <td>
                @Html.TextBoxFor(m => Model.Slug, new { @Class = "easyui-validatebox", @required = "true" })
            </td>
        </tr>
        <tr>
            <td>链接：
            </td>
            <td>
                @Html.TextBoxFor(m => Model.Link, new { @Class = "easyui-validatebox", @required = "true" })
            </td>
        </tr>
        <tr>
            <td>是否置顶：
            </td>
            <td>
                @Html.CheckBoxFor(m => Model.IsTop, new { @Class = "easyui-validatebox", @required = "true" })
            </td>
        </tr>
        <tr>
            <td>开始时间：
            </td>
            <td>
                @if (Model.StartTime.HasValue)
                {
 
                    @Html.TextBox(Html.PropertyNameFor(x => Model.StartTime), Model.StartTime.Value.ToString("yyyy-MM-dd"), new { @class = "easyui-datebox" })
                }
                else
                {
                    @Html.TextBoxFor(m => Model.StartTime, new { @class = "easyui-datebox" })
                }
            </td>
        </tr>
        <tr>
            <td>结束时间：
            </td>
            <td>
                @if (Model.EndTime.HasValue)
                {
 
                    @Html.TextBox(Html.PropertyNameFor(x => Model.EndTime), Model.EndTime.Value.ToString("yyyy-MM-dd"), new { @class = "easyui-datebox" })
                }
                else
                {
                    @Html.TextBoxFor(m => Model.EndTime, new { @class = "easyui-datebox" })
                }
            </td>
        </tr>
    </table>
    <div class="ftitle">广告图片或Flash文件</div>
    <div style="margin-top: 2px">
        @Html.HiddenFor(m => Model.Affix, new { @Class = "attach" })
    </div>
    <div id="some_file_queue" class="some_file_queue" style="margin-left: 4px; float: left">
    </div>
</form>
<link href="@Url.Content("~/Scripts/Uploadify/3.1/uploadify.css")" rel="stylesheet"  type="text/css" />
<script src="@Url.Content("~/Scripts/Uploadify/3.1/swfobject.js")"   type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/Uploadify/3.1/jquery.uploadify-3.1.min.js")"   type="text/javascript"></script>
<script type="text/javascript">
    $(".attach").each(function () {
        var o = $(this);
        var oid = o.attr("id");
        var attach = $('<div id="' + oid + '_attach"><div>');
        o.after(attach);
        attach.uploadify({
            'formData': { "ObjectID": $("#Id").val(), "ObjectModule": "HinnerProduct" },
            'swf': '@Url.Content("~/Scripts/Uploadify/3.1/uploadify.swf")',
            'uploader': '@Url.Action("UploadFiles", "ProductManage", new { area = "Hiner" })',
            'buttonImage': '@Url.Content("~/Themes/images/Snap1.jpg")',
            height: 88,
            'queueID': 'some_file_queue',
            'buttonCursor': 'arrow',
            "buttonText": "点我上传",
            onInit: function (instance) {
                var obj = $("#" + instance.settings.id);

                if (o.val() != '') {
                    obj.find(".uploadify-button").hide();
                    obj.find("img").remove();
                    obj.append('<img width=120 height=88  style="border: 1px solid #95b8e7" src="' + o.val() + '" />');

                }

            },
            onUploadSuccess: function (a, b) {
                var result = $.parseJSON(b);
                if (result.msg != "" && result.msg != undefined) {
                    alert(result.msg);
                } else {
                    var obj = $(this.wrapper[0]);
                    obj.find(".uploadify-button").hide();
                    obj.find("img").remove();
                    obj.append('<img width=120 height=88  style="border: 1px solid #95b8e7" src="' + result.Data.FilePath + '" />');
                    o.val(result.Data.FilePath);
                    // var o = $(this.wrapper[0], "img").attr('src', result.Data.FilePath);
                    //   $("#fileToUpload222-button").html("background-image", "url('" + result.Data.FilePath + "')").before("<img width=80 height=80 src='" + result.Data.FilePath + "' />");

                }
            }
        });
    });
</script>
